﻿using System;
using System.Collections;
using System.Collections.Generic;

using AUV5.Model;
using AUV5.DAL.Interface;

namespace AUV5.DAL.Dao
{
    /// <summary>
    /// 功能：     AccountType业务接口的实现
    /// 作者：     Wilson
    /// 日期：     2012/1/17
    /// 修改日期： 
    /// 修改人：
    /// 修改内容：
    /// </summary>
    public class AccountTypeSqlMapDao : BaseSqlMapDao, AUV5.DAL.Interface.IAccountTypeDao
    {
        private static AccountTypeSqlMapDao instance = new AccountTypeSqlMapDao();

        private AccountTypeSqlMapDao()
        {
            //
            // TODO: 此处添加AccountTypeSqlMapDao的构造函数
            //
        }

        public static IAccountTypeDao GetInstance()
        {
            return instance;
        }

        /// <summary>
        /// 得到最大行数
        /// </summary>
        /// <returns></returns>
        public int GetMaxCounts()
        {
            try
            {
                return (int)ExecuteQueryForObject("SelectAccountTypeByMaxCounts", null);
            }
            catch
            {
                throw;
            }
        }

        /// <summary>
        /// 得到列表
        /// </summary>
        /// <returns></returns>
        public System.Collections.Generic.IList<AccountType> GetList()
        {
            try
            {
                return ExecuteQueryForList<AccountType>("SelectAccountType", null);
            }
            catch
            {
                throw;
            }
        }

        /// <summary>
        /// 通过不同参数得到列表
        /// </summary>
        /// <param name="objParameters"></param>
        /// <returns></returns>
        public System.Collections.Generic.IList<AccountType> GetListByParameters(object objParameters)
        {
            try
            {
                return ExecuteQueryForList<AccountType>("SelectAccountTypeByParameters", objParameters);
            }
            catch
            {
                throw;
            }
        }

        /// <summary>
        /// 得到明细
        /// </summary>
        /// <param name="AccountTypeID"></param>
        /// <returns></returns>
        public AccountType GetDetail(System.String accounttypeid)
        {
            try
            {
                return ExecuteQueryForObject<AccountType>("SelectAccountType", accounttypeid) as AccountType;
            }
            catch
            {
                throw;
            }
        }

        /// <summary>
        /// 新建
        /// </summary>
        /// <param name="accounttype"></param>
        /// <returns></returns>
        public object Add(AccountType accounttype)
        {
            //int id = GetId("AccountType");
            //accounttype.AccountTypeID = id;

            try
            {
                return ExecuteInsert("InsertAccountType", accounttype);
            }
            catch
            {
                throw;
            }
        }

        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="accounttype"></param>
        /// <returns></returns>
        public int Update(AccountType accounttype)
        {
            try
            {
                return ExecuteUpdate("UpdateAccountType", accounttype);
            }
            catch
            {
                throw;
            }
        }

        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="AccountTypeID"></param>
        /// <returns></returns>
        public int Delete(System.String accounttypeid)
        {
            try
            {
                return ExecuteDelete("DeleteAccountType", accounttypeid);
            }
            catch
            {
                throw;
            }
        }
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="accounttype"></param>
        /// <returns></returns>
        public int Delete(AccountType accounttype)
        {
            try
            {
                return ExecuteDelete("DeleteAccountType", accounttype.AccountTypeID);
            }
            catch
            {
                throw;
            }
        }

        #region#通过参数得到集合
        /// <summary>
        /// 通过参数得到集合
        /// 创建人：Wilson
        /// 创建时间：2012-1-17
        /// </summary>
        /// <param name="objParameters"></param>
        /// <returns></returns>
        public IList<AccountType> GetAccountTypeList(object objParameters)
        {
            try
            {
                return ExecuteQueryForList<AccountType>("SelectList", objParameters);
            }
            catch
            {
                throw;
            }
        }
        #endregion
    }
}
